<?php
include_once($_SESSION['ruta_FDSoil'].'/class/functions.class.php'); 
class manejador_bd  extends functions {
        // pg_last_error();
    
    	private $conexion;

	function conectar($db=null) {
	       	include_once $_SESSION['ruta_sistema'].'/config/db.php';  
	       	$this->conexion = pg_connect("host=$servidor port=$port dbname=$dbname user=$usuario password=$password");
		return (!$this->conexion) ? false : $this->conexion;
	}
        
	function cerrar() { 
	        if (!empty($this->conexion)) {
	            pg_close($this->conexion);
	        }
	}

	function ejecutar($sql) {
        	if ($this->conexion)
        	    return pg_query($sql);
    	}
        
	function extraer_resultado($result) {
	       return pg_fetch_result($result);
	}

	function extraer_registro($result){
        	return pg_fetch_row($result);
    	}

	function extraer_arreglo($result){
		return pg_fetch_array($result);
	}

	function extraer_asociativo($result){
		return pg_fetch_assoc($result); 
	} 
        
	function  extraer_todo($result){
		return pg_fetch_all($result);
	}

	function  num_registros($result){
		return pg_num_rows($result);
	}

	function num_campos($result){
        	return pg_num_fields($result);
    	}
}//Fin clase
?>
